package entities.effects;

import java.util.Timer;
import java.util.TimerTask;

import entities.hero.Hero;

public class Silence extends Effect {

	private float duration;
	
	public Silence() {
		
	}
	
	public Silence (float duration) {
		this.duration = duration;
	}
	
	@Override
	public void invokeEffect(Hero target) {
		Timer timer = new Timer();
		
		target.setSilenced(true);
		
		timer.schedule(new ResetSilence(target), (long) (duration * 1000));
	}
}

class ResetSilence extends TimerTask {
	private Hero target;
	
    public ResetSilence(Hero target) {
    	this.target = target;
	}

	public void run() {
		target.setSilenced(false);
    }
  }
